package com.in.ussd.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.in.ussd.model.UssdAdapterModel;

public class SpinnerAdapter extends ArrayAdapter<UssdAdapterModel> {

	private Context context;
	private List<UssdAdapterModel> items;

	public SpinnerAdapter(Context context, int resource,
			List<UssdAdapterModel> items) {
		super(context, resource, items);
		// TODO Auto-generated constructor stub
		this.context = context;
		this.items = items;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public UssdAdapterModel getItem(int position) {
		// TODO Auto-generated method stub
		return  items.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		TextView label = new TextView(context);
		label.setTextSize(16);
		label.setPadding(0, 0, 19, 0);
		label.setText(((UssdAdapterModel) items.get(position)).getUssdDetail());

		return label;
	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		TextView label = new TextView(context);
		label.setTextSize(16);
		label.setPadding(15, 15, 15, 15);
		label.setText(((UssdAdapterModel) items.get(position)).getUssdDetail());

		return label;
	}	
}
